package com.etc;

import org.apache.hadoop.io.Writable;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

/**
 * @Auther: zhezhe
 * @Date: 2018/10/2610:31
 * @Description:
 */
public class FlowBan implements Writable {
    private String phone;
    private int upFlow;
    private int dFlow;
    private int amontFlow;

    public FlowBan(String phone,int upFlow,int dFlow){
        this.phone = phone;
        this.upFlow = upFlow;
        this.dFlow = dFlow;
        this.amontFlow = upFlow + dFlow;

    }

    public FlowBan() {
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public int getUpFlow() {
        return upFlow;
    }

    public void setUpFlow(int upFlow) {
        this.upFlow = upFlow;
    }

    public int getdFlow() {
        return dFlow;
    }

    public void setdFlow(int dFlow) {
        this.dFlow = dFlow;
    }

    public int getAmontFlow() {
        return amontFlow;
    }

    public void setAmontFlow(int amontFlow) {
        this.amontFlow = amontFlow;
    }


    /**
     * 在序列化时要调用的方法
     * @param dataOutput
     * @throws IOException
     */
    @Override
    public void write(DataOutput dataOutput) throws IOException {
        dataOutput.writeUTF(this.phone);
        dataOutput.writeInt(this.upFlow);
        dataOutput.writeInt(this.dFlow);
        dataOutput.writeInt(this.amontFlow);
    }


    /**
     * 在反序列化事要调用的方法
     * @param dataInput
     * @throws IOException
     */
    @Override
    public void readFields(DataInput dataInput) throws IOException {

        this.phone = dataInput.readUTF();
        this.upFlow = dataInput.readInt();
        this.dFlow = dataInput.readInt();
        this.amontFlow = dataInput.readInt();
    }

    @Override
    public String toString() {
        return this.phone+","+this.dFlow+","+this.upFlow+","+this.amontFlow;
    }
}
